__author__ = "ncll"
__data__ = "2020/11/11 16:58"


# key 是唯一的,不可变，字典是可变的
# 如何通过value获得key
# my_dict.items():转换键值对
# setdefault():key存在不改变字典；不存在会添加到字典 get()不会添加
my_dict = {'name': 'cl', 'age': '12'}

# ret = my_dict.get('name1')
ret = my_dict.setdefault('name1', 'pp')
print(ret)
print(my_dict)

# if ('name', 'cl') in my_dict.items():
#     print("ok")
#
# my_dict.fromkeys('name')
# print(tuple(my_dict.keys()))
# print(my_dict.values())
# print(len(my_dict))
# my_dict['age1'] = 111
# del my_dict['age1']
# # print(my_dict.items())
#
# print(my_dict)